﻿@model ContactManagement.Models.DynamicData.EditModelList
@{
    ViewBag.Title = Resources.PageTitles.EditDynamicDataTypeRESX + ": " + Model.CurrentDynamicDataType.Name;
}
<h2>
    @Resources.PageTitles.EditDynamicDataTypeRESX: @Model.CurrentDynamicDataType.Name
    (@Model.CurrentDynamicDataType.GetDynamicDataTypeName())</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    <div>
        @Html.ValidationSummary(true)
        @Html.ShowCustomMessage()
    </div>
    <p>
        @string.Format(Resources.AdminViews.CreateNewListEntryHelpRESX, Resources.AdminViews.NewListEntryRESX)
    </p>
    <fieldset>
        <legend>DynamicDataAddModel</legend>
        <div class="view-item">
            <div class="editor-label">
                @Html.LabelFor(model => model.Name)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </div>
        </div>
        <div class="clear-all">
        </div>
        <div class="view-item">
            <div class="editor-label">
                @Html.LabelFor(model => model.DynamicDataTypeCategories)
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(model => model.DynamicDataTypeCategoryId, Model.DynamicDataTypeCategories, Resources.GlobalStrings.PleaseSelectItemsRESX)
                @Html.ValidationMessageFor(model => model.DynamicDataTypeCategoryId)
            </div>
        </div>
        <div class="clear-all">
        </div>
        <div class="view-item">
            <div class="editor-label">
                @Html.LabelFor(model => model.IsVisible)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.IsVisible)
                @Html.ValidationMessageFor(model => model.IsVisible)
            </div>
        </div>
        <div class="clear-all">
        </div>
        <div class="view-item">
            <div class="editor-label">
                @Html.LabelFor(model => model.IsFilterable)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.IsFilterable)
                @Html.ValidationMessageFor(model => model.IsFilterable)
            </div>
        </div>
        <div class="clear-all">
        </div>
        <div class="view-item">
            <div class="editor-label">
                @Html.LabelFor(model => model.IsRequired)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.IsRequired)
                @Html.ValidationMessageFor(model => model.IsRequired)
            </div>
        </div>
        <div class="clear-all">
        </div>
        <div class="view-item">
            <div class="editor-label">
                @Html.LabelFor(model => model.SortId)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.SortId)
                @Html.ValidationMessageFor(model => model.SortId)
            </div>
        </div>
        <div class="clear-all">
        </div>
        <div class="view-item">
            <div class="editor-label">
                @Html.LabelFor(model => model.FormatString)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.FormatString)
                @Html.ValidationMessageFor(model => model.FormatString)
            </div>
        </div>
        <div class="clear-all">
        </div>
        <div class="view-item">
            <div class="editor-label">
                @Html.LabelFor(model => model.CustomCssClass)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.CustomCssClass)
                @Html.ValidationMessageFor(model => model.CustomCssClass)
            </div>
        </div>
        <div class="clear-all">
        </div>
        <div class="view-item">
            <div class="editor-label">
                @Html.LabelFor(model => model.Description)
            </div>
            <div class="editor-field">
                @Html.TextAreaFor(model => model.Description)
                @Html.ValidationMessageFor(model => model.Description)
            </div>
        </div>
        @* Tabelle mit den Listeneinträgen die hinzugefügt werden können, immer nur ein Wert nach dem anderen. *@
        <div class="clear-all">
            <div class="view-item">
                <div class="editor-label">
                    @Html.LabelFor(model => model.ListEntries)
                </div>
                <div class="editor-field">
                    <table>
                        <tr>
                            <th>
                                @Resources.AccountViews.OptionsRESX
                            </th>
                            <th>
                                @Resources.AdminViews.ListEntryNameRESX
                            </th>
                            <th>
                                @Resources.AdminViews.SortIDRESX
                            </th>
                        </tr>
                        @foreach (var eListEnty in Model.ListEntries)
                        {
                            <tr>
                                <td>
                                    @if (eListEnty.ID > 0)
                                    {
                                        // Einen Link zum Löschen des aktuellen Listeneintrages, dieser kann letztendlich aber nur gelöscht werden wenn der Eintrag noch nicht verwendet wird, bzw. die Id > 0 ist.
                                        @Html.ActionLink(Resources.Navigation.DeleteRESX, EActionDynamicData.DeleteListEntry.ToString(), new { id = Model.CurrentDynamicDataType.ID, listEntryId = eListEnty.ID })
                                    }
                                    else
                                    {
                                        @Resources.AdminViews.NewListEntryRESX
                                    }
                                </td>
                                <td>
                                    <input id="@String.Format("{0}_{1}", WebConstants.ListEntryName, eListEnty.ID)" type="text" value="@eListEnty.Name" name="@String.Format("{0}_{1}", WebConstants.ListEntryName, eListEnty.ID)" class="valid" />
                                </td>
                                <td>
                                    <input id="@String.Format("{0}_{1}", WebConstants.ListEntrySortId, eListEnty.ID)" type="text" value="@eListEnty.SortId" name="@String.Format("{0}_{1}", WebConstants.ListEntrySortId, eListEnty.ID)" class="valid" />
                                </td>
                            </tr>
                        }
                    </table>
                </div>
            </div>
            <div class="clear-all">
            </div>
            <p>
                <input type="submit" value="@Resources.Navigation.SaveChangesRESX" />
            </p>
    </fieldset>
}
<div>
    @Html.ActionLink(@Resources.Navigation.BackToListRESX, EActionDynamicData.DynamicDataTypesList.ToString())
    |
    @Html.ActionLink(@Resources.Navigation.DynamicDataEditGroupRightsRESX, EActionDynamicData.EditGroupRights.ToString(), new { id = Model.CurrentDynamicDataType.ID })
</div>
